<% layout('/layouts/default.html', {title: '服务订单管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('服务订单管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('order:serviceorder:serviceOrder:edit')){ %>
					<a href="${ctx}/order/serviceorder/serviceOrder/form" class="btn btn-default btnTool" title="${text('新增服务订单')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${serviceOrder}" action="${ctx}/order/serviceorder/serviceOrder/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('编号')}：</label>
					<div class="control-inline">
						<#form:input path="serviceOrderCode" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('国内资方')}：</label>
					<div class="control-inline width-120">
						<#form:select path="investorId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('代理公司')}：</label>
					<div class="control-inline width-120" >
						<#form:treeselect id="company" title="${text('公司选择')}"
							path="company.companyCode" labelPath="company.companyName"
							url="${ctx}/sys/company/treeData" allowClear="true"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('年度汽车买卖协议')}：</label>
					<div class="control-inline">
						<#form:input path="yearCarSalePurchaseAgreementId" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('客户')}：</label>
					<div class="control-inline width-120">
						<#form:treeselect id="customer" title="${text('客户选择')}"
						path="customer.customerId" labelPath="customer.customerName"
						url="${ctx}/base/customer/customer/treeData" canSelectRoot="true" canSelectParent="true"
						class=" required" allowClear="true"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('汽车买卖合同号')}：</label>
					<div class="control-inline">
						<#form:input path="contractNumber" maxlength="50" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('供应链服务协议')}：</label>
					<div class="control-inline">
						<#form:input path="supplyChainServiceAgreementId" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('外商')}：</label>
					<div class="control-inline width-120">
						<#form:select path="foreignBusinessmenId" items="${hwzfList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('采购委托书号')}：</label>
					<div class="control-inline">
						<#form:input path="purchaseCommissionNumber" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('供货外商')}：</label>
					<div class="control-inline width-120">
						<#form:select path="supplierId" items="${supplierList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('外贸合同号')}：</label>
					<div class="control-inline">
						<#form:input path="foreignTradeContractNumber" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('付款方式')}：</label>
					<div class="control-inline width-120">
						<#form:select path="paymentMethod" dictType="payment_method" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('订单日期')}：</label>
					<div class="control-inline">
						<#form:input path="date_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="date_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="date_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="orderStatus" dictType="order_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('车辆')}：</label>
					<div class="control-inline width-120">
						<#form:select path="serviceOrderDetail.carId" items="${tcarList}"
						itemLabel="carName" itemValue="carId" blankOption="true" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('最晚装船日期')}：</label>
					<div class="control-inline">
						<#form:input path="latestShipmentDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="latestShipmentDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="latestShipmentDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('装运港')}：</label>
					<div class="control-inline width-120">
						<#form:select path="fromPort" dictType="erp_harbor_list" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('目的港')}：</label>
					<div class="control-inline width-120">
						<#form:select path="toPort" dictType="erp_harbor_list" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('贸易术语')}：</label>
					<div class="control-inline width-120">
						<#form:select path="tradeTerm" dictType="trade_term" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('币种')}：</label>
					<div class="control-inline width-120">
						<#form:select path="currency" dictType="sys_bizhong" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('创建者')}：</label>
					<div class="control-inline width-120">
						<#form:select path="createBy" items="${listUser}"
						itemLabel="userName" itemValue="userCode" blankOption="true" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('创建时间')}：</label>
					<div class="control-inline">
						<#form:input path="createDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="createDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="createDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("编号")}', name:'serviceOrderCode', index:'a.service_order_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/order/serviceorder/serviceOrder/detail?serviceOrderId='+row.serviceOrderId+'" class="btnList" data-title="${text("编辑服务订单")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("版本号")}', name:'version', index:'a.version', width:150, align:"center"},
		{header:'${text("操作")}', name:'actions', width:140, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('order:serviceorder:serviceOrder:view')){ %>
			actions.push('<a href="${ctx}/order/serviceorder/serviceOrder/detail?serviceOrderId='+row.serviceOrderId+'" class="btnList" title="${text("查看服务订单")}"><i class="fa fa-file-text-o"></i></a>&nbsp;');
			<% } %>

			if(row.approveStatus == "1" || row.approveStatus == "4"){
			<% if(hasPermi('order:serviceorder:serviceOrder:edit')){ %>
				actions.push('<a href="${ctx}/order/serviceorder/serviceOrder/form?serviceOrderId='+row.serviceOrderId+'" class="btnList" title="${text("编辑服务订单")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				<% } %>
			<% if(hasPermi('order:serviceorder:serviceOrder:delete')){ %>
				actions.push('<a href="${ctx}/order/serviceorder/serviceOrder/delete?serviceOrderId='+row.serviceOrderId+'" class="btnList" title="${text("删除服务订单")}" data-confirm="${text("确认要删除该服务订单吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
					<% } %>
			}

			return actions.join('');
		}},
		{header:'${text("国内资方")}', name:'investor.supplierName', index:'e.supplier_name', width:150, align:"center"},
		{header:'${text("代理公司")}', name:'company.companyName', index:'a.company_id', width:150, align:"center"},
		{header:'${text("年度汽车买卖协议")}', name:'yearCarSalePurchaseAgreementId', index:'a.year_car_sale_purchase_agreement_id', width:150, align:"left"},
		{header:'${text("客户")}', name:'customer.customerName', index:'c.customer_name', width:150, align:"center"},
		{header:'${text("汽车买卖合同号")}', name:'contractNumber', index:'a.contract_number', width:150, align:"left"},
		{header:'${text("供应链服务协议")}', name:'supplyChainServiceAgreementId', index:'a.supply_chain_service_agreement_id', width:150, align:"left"},
		{header:'${text("外商")}', name:'foreignBusinessmen.supplierName', index:'f.supplier_name', width:150, align:"center"},
		{header:'${text("采购委托书号")}', name:'purchaseCommissionNumber', index:'a.purchase_commission_number', width:150, align:"left"},
		{header:'${text("供货外商")}', name:'supplier.supplierName', index:'d.supplier_name', width:150, align:"center"},
		{header:'${text("外贸合同号")}', name:'foreignTradeContractNumber', index:'a.foreign_trade_contract_number', width:150, align:"left"},
		{header:'${text("付款方式")}', name:'paymentMethod', index:'a.payment_method', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('payment_method')}, val, '${text("未知")}', true);
		}},
		{header:'${text("订单日期")}', name:'date', index:'a.date', width:150, align:"center"},
		{header:'${text("状态")}', name:'orderStatus', index:'a.order_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('order_status')}, val, '${text("未知")}', true);
		}},
		{header:'${text("审批状态")}', name:'approveStatus', index:'a.approve_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('finance_bill_status')}, val, '${text("未知")}', true);
		}},
		{header:'${text("最晚装船日期")}', name:'latestShipmentDate', index:'a.latest_shipment_date', width:150, align:"center"},
		{header:'${text("装运港")}', name:'fromPort', index:'a.from_port', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('erp_harbor_list')}, val, '${text("未知")}', true);
		}},
		{header:'${text("目的港")}', name:'toPort', index:'a.to_port', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('erp_harbor_list')}, val, '${text("未知")}', true);
		}},
		{header:'${text("贸易术语")}', name:'tradeTerm', index:'a.trade_term', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('trade_term')}, val, '${text("未知")}', true);
		}},
		{header:'${text("币种")}', name:'currency', index:'a.currency', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_bizhong')}, val, '${text("未知")}', true);
		}},
		{header:'${text("资方利润")}', name:'investorProfit', index:'a.investor_profit', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text("批单号")}', name:'lotNumber', index:'a.lot_number', width:150, align:"left"},
		// {header:'${text("保证金、费用比例")}', name:'marginExpenseRatioId', index:'a.margin_expense_ratio_id', width:150, align:"left"},
		{header:'${text("保证金比例")}', name:'marginRatio', index:'a.margin_ratio', width:150, align:"left"},
		{header:'${text("押汇比例")}', name:'negotiatedRatioId', index:'a.negotiated_ratio_id', width:150, align:"left"},
		{header:'${text("预收费比例")}', name:'prePayRatio', index:'a.pre_pay_ratio', width:150, align:"left"},
		{header:'${text("暂定汇率")}', name:'tentativeExchangeRate', index:'a.tentative_exchange_rate', width:150, align:"left"},
		{header:'${text("车辆主要配置/备注")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("创建者")}', name:'createBy', index:'a.create_by', width:150, align:"left"},
		{header:'${text("创建时间")}', name:'createDate', index:'a.create_date', width:150, align:"center"}
	],
	frozenCols: true,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>